home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / GameKit / gamekit-1 / GKHSLocalServer.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  63 lines

  1. // GKHSLocalServer.m
  2. // under development; anything with ***** is yet to be completed
  3.  
  4. // This class is the actual high score server for any given game.
  5. // This subclass handles local high score files. 
  6.  
  7. // I need to do exception handling in here to catch any DO problems,
  8. // but haven't got around to it yet, so exceptions will currently crash
  9. // the server. :-<  *****
  10.  
  11. #import <appkit/appkit.h>
  12. #import <daymisckit/daymisckit.h>
  13. #import <gamekit/gamekit.h>
  14. #import <remote/NXProxy.h>
  15. #import <objc/objc-runtime.h>
  16. #import <objc/objc-load.h>
  17.  
  18.  
  19. @implementation GKHSLocalServer
  20.  
  21. - initForGame:(const char *)name // designated initializer
  22. {
  23.     if (![super initForGame:name]) return nil;
  24.     if (!gameInfo) { // these are available locally, so set them up now.
  25.         [self setTemplate:[[[NXApp delegate]
  26.                 highScoreController] tableProtoType]];
  27.         [self setGameInfo:[[NXApp delegate] gameInfo]];
  28.     }
  29.     return self;
  30. }
  31.  
  32. - (const char *)pathToTables
  33. {    // High score files are stored inside the app wrapper.
  34.     // any unloaded slots will be expected to be in the wrapper, too.
  35.     return [NXApp appDirectory];
  36. }
  37.  
  38. - (oneway)setGameInfo:(bycopy in id)info
  39. {
  40.     [super setGameInfo:info];
  41.     // Really need to set up for which table this is ***** right now assume 0
  42.     // This sets up the max # high scores for a local server
  43.     [table setMaxScoresPerPlayer:[gameInfo maxScoresPerPlayerTable:0 net:NO]];
  44. #ifdef NOISYDEBUG
  45.     fprintf(stderr, "GKHSLocalServer:  maxScorePerPlayer is %d.\n",
  46.             [gameInfo maxScoresPerPlayerTable:0 net:NO]);
  47. #endif
  48.     [self save];
  49.     return self;
  50. }
  51.  
  52. - save
  53. {    // make sure that the high score file is world read/write so everyone
  54.     // can alter it (and save their scores)
  55.     char *cmd = malloc(1024);
  56.     [super save];
  57.     sprintf(cmd, "chmod 666 %s", [scoreFile stringValue]);
  58.     system(cmd);
  59.     free(cmd);
  60.     return self;
  61. }
  62.  
  63. @end